from scipy import constants
import numpy as np


class Wave:
    """
    规则波波浪
    """

    def __init__(self, cfg, f):
        omega = 2 * constants.pi * f
        self.omega_e = encouter_omega(omega, cfg["v"])
        self.k0 = wave_number(omega)
        self.amplitude = cfg["amplitude"]

    def wave_height(self, x, y, t):
        "计算波浪高度"
        return np.sin(self.k0 * x + self.omega_e * t)


def encouter_omega(omega, v):
    "计算遭遇频率"
    return omega + omega**2 / constants.g * v


def wave_number(omega):
    "计算波数"
    return omega**2 / constants.g
